#include "test.h"
#include <opencv2\opencv.hpp>

using namespace cv;
using namespace std;

void printMatrix(const Mat& mat)
{
    cout << "Matrix = " << endl << " " << mat << endl << endl;
}

int test03(int argc, char** argv)
{
    Mat M(2,2, CV_8UC3, Scalar(0,0,255));
    printMatrix(M);

    //int sz[3] = { 2,2,2 };
    //Mat ThreeD(3, sz, CV_8UC(1), Scalar::all(0));
    //printMatrix(ThreeD);

    IplImage* img = cvLoadImage("C:\\ProgramsOrTools\\OpenCV2.4.3\\samples\\cpp\\lena.jpg", 1);
    Mat mtrx(img);
    
    Mat X;
    X.create(4,4, CV_8UC(2));
    printMatrix(X);

    Mat E = Mat::eye(4,4, CV_64F);
    printMatrix(E);
    Mat O = Mat::ones(2,2, CV_32F);
    printMatrix(O);
    Mat Z = Mat::zeros(3,3, CV_8UC1);
    printMatrix(Z);

    Mat C = (Mat_<double>(3,3) << 0,-1,0,-1,5,-1,0,-1,0);
    printMatrix(C);

    Mat rowClone = C.row(1).clone();
    printMatrix(rowClone);

    Mat R = Mat(3,2, CV_8UC3);
    randu(R, Scalar::all(0), Scalar::all(255));
    printMatrix(R);

    cout << "Default formatting:" << C << endl << endl;
    cout << "Python formatting:" << format(C, "python") << endl << endl;
    cout << "CSV formatting:" << format(C, "csv") << endl << endl;
    cout << "C formatting:" << format(C, "c") << endl << endl;

    Point2f P(5,1);
    cout << "point:" << P << endl << endl;

    Point3f P3f(2,6,7);
    cout << "point:" << P3f << endl << endl;

    vector<float> v;
    v.push_back((float)CV_PI);
    v.push_back(2);
    v.push_back(3.01f);

    cout << "Vector of floats via Mat = " << Mat(v) << endl << endl;

    vector<Point2f> vec(20);
    for (size_t i = 0; i < vec.size(); ++i)
        vec[i] = Point2f((float)(i*5), (float)(i%7));
    //cout << "Vector of points = " << format(vec, "csv") << endl << endl;
    cout << "Vector of points = " << vec << endl << endl;

    return 0;
}